home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Source / GNU / cc / va-m88k.h < prev    next >
C/C++ Source or Header  |  1993-10-13  |  3KB  |  81 lines

  1. /* GNU C varargs support for the Motorola 88100  */
  2.  
  3. /* Define __gnuc_va_list.  */
  4.  
  5. #ifndef __GNUC_VA_LIST
  6. #define __GNUC_VA_LIST
  7.  
  8. typedef struct
  9. {
  10.   int  __va_arg;        /* argument number */
  11.   int *__va_stk;        /* start of args passed on stack */
  12.   int *__va_reg;        /* start of args passed in regs */
  13. } __gnuc_va_list;
  14. #endif /* not __GNUC_VA_LIST */
  15.  
  16. /* If this is for internal libc use, don't define anything but
  17.    __gnuc_va_list.  */
  18. #if defined (_STDARG_H) || defined (_VARARGS_H)
  19.  
  20. #ifdef _STDARG_H /* stdarg.h support */
  21.  
  22. #if __GNUC__ > 1 /* GCC 2.0 and beyond */
  23. #define va_start(AP,LASTARG) ((AP) = *(__gnuc_va_list *)__builtin_saveregs())
  24. #else
  25. #define va_start(AP,LASTARG) \
  26.   ( (AP).__va_reg = (int *) __builtin_saveregs2(0), \
  27.     (AP).__va_stk = (int *) __builtin_argptr(), \
  28.     (AP).__va_arg = (int) (__builtin_argsize() + 3) / 4 )
  29. #endif
  30.  
  31. #else /* varargs.h support */
  32.  
  33. #if __GNUC__ > 1 /* GCC 2.0 and beyond */
  34. #define va_start(AP) ((AP) = *(__gnuc_va_list *)__builtin_saveregs())
  35. #else
  36. #define va_start(AP) \
  37.   ( (AP).__va_reg = (int *) __builtin_saveregs2(1), \
  38.     (AP).__va_stk = (int *) __builtin_argptr(), \
  39.     (AP).__va_arg = (int) (__builtin_argsize() - 4 + 3) / 4 )
  40. #endif
  41. #define va_alist __va_1st_arg
  42. #define va_dcl register int va_alist;
  43.  
  44. #endif /* _STDARG_H */
  45.  
  46. /* Avoid trouble between this file and _int_varargs.h under DG/UX.  This file
  47.    can be included by <stdio.h> and others and provides definitions of
  48.    __va_size and __va_reg_p and  a va_list typedef.  Avoid defining va_list
  49.    again with _VA_LIST.  */
  50. #ifdef __INT_VARARGS_H
  51. #undef __va_size
  52. #undef __va_reg_p
  53. #define __gnuc_va_list va_list
  54. #define _VA_LIST
  55. #define _VA_LIST_
  56. #else
  57. /* Similarly, if this gets included first, do nothing in _int_varargs.h.  */
  58. #define __INT_VARARGS_H
  59. #endif
  60.  
  61. #define __va_reg_p(TYPE) \
  62.   (__builtin_classify_type(*(TYPE *)0) < 12 \
  63.    ? sizeof(TYPE) <= 8 : sizeof(TYPE) == 4 && __alignof__(TYPE) == 4)
  64.  
  65. #define    __va_size(TYPE) ((sizeof(TYPE) + 3) >> 2)
  66.  
  67. /* We cast to void * and then to TYPE * because this avoids
  68.    a warning about increasing the alignment requirement.  */
  69. #define va_arg(AP,TYPE)                               \
  70.   ( (AP).__va_arg = (((AP).__va_arg + (1 << (__alignof__(TYPE) >> 3)) - 1) \
  71.              & ~((1 << (__alignof__(TYPE) >> 3)) - 1))           \
  72.     + __va_size(TYPE),                               \
  73.     *((TYPE *) (void *) ((__va_reg_p(TYPE)                   \
  74.               && (AP).__va_arg < 8 + __va_size(TYPE)       \
  75.               ? (AP).__va_reg : (AP).__va_stk)           \
  76.              + ((AP).__va_arg - __va_size(TYPE)))))
  77.  
  78. #define va_end(AP)
  79.  
  80. #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
  81.